<?php
namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class UserCoupon extends Model
{

    use SoftDeletes;

    protected $table = 'user_coupon';

    /**
     * 优惠券
     * @return \Illuminate\Database\Eloquent\Relations\HasOne
     */
    public function coupon()
    {

        $select_field = ['id', 'name', 'type', 'validity_day', 'coupon_value', 'use_time_start', 'use_time_end', 'use_full','rules'];

        return $this->hasOne(Coupon::class, 'id', 'coupon_id')
            ->where('status', 1)
            ->select($select_field);

    }
}
